import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/login',
    name: 'LOGIN',
    component: () => import('@/views/login/pages'),
    meta: {
      title: '登录'
    }
  },
  {
    path: '/home',
    name: 'HOME',
    component: () => import('@/views/home'),
    meta: {
      title: '推八利息减免计算器'
    }
  },
  {
    path: '/search',
    name: 'SEARCH',
    component: () => import('@/views/search'),
    meta: {
      title: '查询'
    }
  }
]

const router = new VueRouter({
  // mode: 'history',
  // base: process.env.BASE_URL,
  routes
})

router.beforeEach((to, from, next) => {
  to.meta.title && (document.title = to.meta.title)
  next()
})

export default router
